
from config import BASH_HOST

import logging
class RegLoginApi:

    def __init__(self,ses):
        self.ses=ses

    # 获取图片验证码接口
    def get_img_verify_code(self, r):
        url1=BASH_HOST+"/common/public/verifycode1/{}".format(r)
        res=self.ses.get(url=url1)
        logging.info(f"获取图片验证码接口返回的响应状态码:{res}")
        return res

    # 获取短信验证码接口
    def get_phone_verify_code(self, phone_v, img_code_v, type_v="reg"):
        url2=BASH_HOST+"/member/public/sendSms"
        from_data= {"phone":phone_v,"imgVerifyCode":img_code_v,"type":type_v}
        resp=self.ses.post(url=url2,data=from_data)
        logging.info("获取短信验证码接口返回的响应状态码:{}".format(resp.json()))
        return resp

    # 注册接口
    def user_register(self, form_dict):
        url3=BASH_HOST+"/member/public/reg"
        form_data=form_dict
        resp=self.ses.post(url=url3,data=form_data)
        logging.info("获取注册验证码接口返回的响应状态码:{}".format(resp.json()))
        return resp

    # 登录接口
    def user_login(self, username_v, pwd_v):
        url3 = BASH_HOST + "/member/public/login"
        form_data = {"keywords":username_v,"password":pwd_v}
        resp = self.ses.post(url=url3, data=form_data)
        logging.info("获取登录验证码接口返回的响应状态码:{}".format(resp.json()))
        return resp
